import { NextResponse } from 'next/server';
import prisma from '@/lib/prisma';

export async function POST(
  request: Request,
  { params }: { params: { id: string } }
) {
  try {
    const { id: musicId } = params;
    console.log(musicId)

    // 查找当前音乐
    const music = await prisma.vms_music.findUnique({
      where: { id: musicId }
    });

    if (!music) {
      return NextResponse.json(
        { error: 'Music not found' },
        { status: 404 }
      );
    }

    // 更新点赞数（假设score字段存储点赞数）
    const updatedMusic = await prisma.vms_music.update({
      where: { id: musicId },
      data: {
        score: (music.score || 0) + 1
      }
    });

    return NextResponse.json(updatedMusic);
  } catch (error) {
    return NextResponse.json(
      { error: 'Failed to update like count' },
      { status: 500 }
    );
  }
}
